total = 0
f = open('names.txt','r')
lines = f.read().split(',')
for x in range(len(lines)):
	lines[x] = lines[x][1:-1]
lines.sort()
for x in range(len(lines)):
	temp = 0
	for char in lines[x]:
		temp = temp + (ord(char)-64)
		print((ord(char)-64))
	total = total + (temp * (x+1))
print(total)